using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

using MULENetworking;

namespace MULEServer
{
    [Serializable]
    class Game : MarshalByRefObject, IGame
    {
        string nameOfTheGame;
        IStore gameStore;
        int currTimer, maxTimer, gameState, currPlayer, currTurn, gameLevel;
        IPlayer p1, p2, p3, p4;
        ArrayList readyNames;
        IMap gameMap;

        public Game(String name, int level)
        {
            //TODO: init gameStore
            currTurn = -1;
            currTimer = -1;
            currPlayer = -1;
            maxTimer = -1;
            gameLevel = level;
            p1 = null;
            p2 = null;
            p3 = null;
            p4 = null;
            nameOfTheGame = name;
            readyNames = new ArrayList();
            gameMap = new ServerMap();
        }

        #region IGame Members

        public string GameName
        {
            get
            {
                return nameOfTheGame;
            }
            set
            {
                nameOfTheGame = value;
            }
        }

        public int GameLevel
        {
            get
            {
                return gameLevel;
            }
        }

        public IMap GameMap
        {
            get
            {
                return gameMap;
            }
            set
            {
                gameMap = value;
            }
        }

        public IStore GameStore
        {
            get
            {
                return gameStore;
            }
            set
            {
                gameStore = value;
            }
        }

        public int TimerMax
        {
            get
            {
                return maxTimer;
            }
            set
            {
                maxTimer = value;
            }
        }

        public int CurrentTimer
        {
            get
            {
                return currTimer;
            }
            set
            {
                currTimer = value;
            }
        }

        public int GameState
        {
            get
            {
                return gameState;
            }
            set
            {
                gameState = value;
            }
        }

        public int CurrentPlayer
        {
            get
            {
                return currPlayer;
            }
            set
            {
                currPlayer = value;
            }
        }

        public int CurrentTurn
        {
            get
            {
                return currTurn;
            }
            set
            {
                currTurn = value;
            }
        }

        public IPlayer Player1
        {
            get
            {
                return p1;
            }
            set
            {
                p1 = value;
            }
        }

        public IPlayer Player2
        {
            get
            {
                return p2;
            }
            set
            {
                p2 = value;
            }
        }

        public IPlayer Player3
        {
            get
            {
                return p3;
            }
            set
            {
                p3 = value;
            }
        }

        public IPlayer Player4
        {
            get
            {
                return p4;
            }
            set
            {
                p4 = value;
            }
        }

        public ArrayList ReadyNames
        {
            get
            {
                return readyNames;
            }
            set
            {
                readyNames = value;
            }
        }

        public override string ToString()
        {
            return nameOfTheGame;
        }

        #endregion

        #region IGame Members


        public IPlayer[] PlayerList
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        #endregion
    }
}
